/**
 * <copyright>
 * </copyright>
 *
 * $Id$
 */
package com.maschinenstuermer.profiler.trace.impl;

import com.maschinenstuermer.profiler.trace.CompositeInvocation;
import com.maschinenstuermer.profiler.trace.MethodInvocation;
import com.maschinenstuermer.profiler.trace.SqlStatementExecution;
import com.maschinenstuermer.profiler.trace.TracePackage;
import com.maschinenstuermer.profiler.trace.Transaction;

import java.util.Collection;

import org.eclipse.emf.common.notify.NotificationChain;

import org.eclipse.emf.common.util.EList;

import org.eclipse.emf.ecore.EClass;
import org.eclipse.emf.ecore.InternalEObject;

import org.eclipse.emf.ecore.util.BasicFeatureMap;
import org.eclipse.emf.ecore.util.FeatureMap;
import org.eclipse.emf.ecore.util.InternalEList;

/**
 * <!-- begin-user-doc -->
 * An implementation of the model object '<em><b>Composite Invocation</b></em>'.
 * <!-- end-user-doc -->
 * <p>
 * The following features are implemented:
 * <ul>
 *   <li>{@link com.maschinenstuermer.profiler.trace.impl.CompositeInvocationImpl#getGroup <em>Group</em>}</li>
 *   <li>{@link com.maschinenstuermer.profiler.trace.impl.CompositeInvocationImpl#getMethodInvocation <em>Method Invocation</em>}</li>
 *   <li>{@link com.maschinenstuermer.profiler.trace.impl.CompositeInvocationImpl#getSqlStatementExecution <em>Sql Statement Execution</em>}</li>
 *   <li>{@link com.maschinenstuermer.profiler.trace.impl.CompositeInvocationImpl#getTransaction <em>Transaction</em>}</li>
 * </ul>
 * </p>
 *
 * @generated
 */
public abstract class CompositeInvocationImpl extends InvocationImpl implements CompositeInvocation {
	/**
	 * The cached value of the '{@link #getGroup() <em>Group</em>}' attribute list.
	 * <!-- begin-user-doc -->
	 * <!-- end-user-doc -->
	 * @see #getGroup()
	 * @generated
	 * @ordered
	 */
	protected FeatureMap group;

	/**
	 * <!-- begin-user-doc -->
	 * <!-- end-user-doc -->
	 * @generated
	 */
	protected CompositeInvocationImpl() {
		super();
	}

	/**
	 * <!-- begin-user-doc -->
	 * <!-- end-user-doc -->
	 * @generated
	 */
	@Override
	protected EClass eStaticClass() {
		return TracePackage.Literals.COMPOSITE_INVOCATION;
	}

	/**
	 * <!-- begin-user-doc -->
	 * <!-- end-user-doc -->
	 * @generated
	 */
	public FeatureMap getGroup() {
		if (group == null) {
			group = new BasicFeatureMap(this, TracePackage.COMPOSITE_INVOCATION__GROUP);
		}
		return group;
	}

	/**
	 * <!-- begin-user-doc -->
	 * <!-- end-user-doc -->
	 * @generated
	 */
	public EList<MethodInvocation> getMethodInvocation() {
		return getGroup().list(TracePackage.Literals.COMPOSITE_INVOCATION__METHOD_INVOCATION);
	}

	/**
	 * <!-- begin-user-doc -->
	 * <!-- end-user-doc -->
	 * @generated
	 */
	public EList<SqlStatementExecution> getSqlStatementExecution() {
		return getGroup().list(TracePackage.Literals.COMPOSITE_INVOCATION__SQL_STATEMENT_EXECUTION);
	}

	/**
	 * <!-- begin-user-doc -->
	 * <!-- end-user-doc -->
	 * @generated
	 */
	public EList<Transaction> getTransaction() {
		return getGroup().list(TracePackage.Literals.COMPOSITE_INVOCATION__TRANSACTION);
	}

	/**
	 * <!-- begin-user-doc -->
	 * <!-- end-user-doc -->
	 * @generated
	 */
	@Override
	public NotificationChain eInverseRemove(InternalEObject otherEnd, int featureID, NotificationChain msgs) {
		switch (featureID) {
			case TracePackage.COMPOSITE_INVOCATION__GROUP:
				return ((InternalEList<?>)getGroup()).basicRemove(otherEnd, msgs);
			case TracePackage.COMPOSITE_INVOCATION__METHOD_INVOCATION:
				return ((InternalEList<?>)getMethodInvocation()).basicRemove(otherEnd, msgs);
			case TracePackage.COMPOSITE_INVOCATION__SQL_STATEMENT_EXECUTION:
				return ((InternalEList<?>)getSqlStatementExecution()).basicRemove(otherEnd, msgs);
			case TracePackage.COMPOSITE_INVOCATION__TRANSACTION:
				return ((InternalEList<?>)getTransaction()).basicRemove(otherEnd, msgs);
		}
		return super.eInverseRemove(otherEnd, featureID, msgs);
	}

	/**
	 * <!-- begin-user-doc -->
	 * <!-- end-user-doc -->
	 * @generated
	 */
	@Override
	public Object eGet(int featureID, boolean resolve, boolean coreType) {
		switch (featureID) {
			case TracePackage.COMPOSITE_INVOCATION__GROUP:
				if (coreType) return getGroup();
				return ((FeatureMap.Internal)getGroup()).getWrapper();
			case TracePackage.COMPOSITE_INVOCATION__METHOD_INVOCATION:
				return getMethodInvocation();
			case TracePackage.COMPOSITE_INVOCATION__SQL_STATEMENT_EXECUTION:
				return getSqlStatementExecution();
			case TracePackage.COMPOSITE_INVOCATION__TRANSACTION:
				return getTransaction();
		}
		return super.eGet(featureID, resolve, coreType);
	}

	/**
	 * <!-- begin-user-doc -->
	 * <!-- end-user-doc -->
	 * @generated
	 */
	@SuppressWarnings("unchecked")
	@Override
	public void eSet(int featureID, Object newValue) {
		switch (featureID) {
			case TracePackage.COMPOSITE_INVOCATION__GROUP:
				((FeatureMap.Internal)getGroup()).set(newValue);
				return;
			case TracePackage.COMPOSITE_INVOCATION__METHOD_INVOCATION:
				getMethodInvocation().clear();
				getMethodInvocation().addAll((Collection<? extends MethodInvocation>)newValue);
				return;
			case TracePackage.COMPOSITE_INVOCATION__SQL_STATEMENT_EXECUTION:
				getSqlStatementExecution().clear();
				getSqlStatementExecution().addAll((Collection<? extends SqlStatementExecution>)newValue);
				return;
			case TracePackage.COMPOSITE_INVOCATION__TRANSACTION:
				getTransaction().clear();
				getTransaction().addAll((Collection<? extends Transaction>)newValue);
				return;
		}
		super.eSet(featureID, newValue);
	}

	/**
	 * <!-- begin-user-doc -->
	 * <!-- end-user-doc -->
	 * @generated
	 */
	@Override
	public void eUnset(int featureID) {
		switch (featureID) {
			case TracePackage.COMPOSITE_INVOCATION__GROUP:
				getGroup().clear();
				return;
			case TracePackage.COMPOSITE_INVOCATION__METHOD_INVOCATION:
				getMethodInvocation().clear();
				return;
			case TracePackage.COMPOSITE_INVOCATION__SQL_STATEMENT_EXECUTION:
				getSqlStatementExecution().clear();
				return;
			case TracePackage.COMPOSITE_INVOCATION__TRANSACTION:
				getTransaction().clear();
				return;
		}
		super.eUnset(featureID);
	}

	/**
	 * <!-- begin-user-doc -->
	 * <!-- end-user-doc -->
	 * @generated
	 */
	@Override
	public boolean eIsSet(int featureID) {
		switch (featureID) {
			case TracePackage.COMPOSITE_INVOCATION__GROUP:
				return group != null && !group.isEmpty();
			case TracePackage.COMPOSITE_INVOCATION__METHOD_INVOCATION:
				return !getMethodInvocation().isEmpty();
			case TracePackage.COMPOSITE_INVOCATION__SQL_STATEMENT_EXECUTION:
				return !getSqlStatementExecution().isEmpty();
			case TracePackage.COMPOSITE_INVOCATION__TRANSACTION:
				return !getTransaction().isEmpty();
		}
		return super.eIsSet(featureID);
	}

	/**
	 * <!-- begin-user-doc -->
	 * <!-- end-user-doc -->
	 * @generated
	 */
	@Override
	public String toString() {
		if (eIsProxy()) return super.toString();

		StringBuffer result = new StringBuffer(super.toString());
		result.append(" (group: ");
		result.append(group);
		result.append(')');
		return result.toString();
	}

} //CompositeInvocationImpl
